import http from '@/plugins/axios'

export function getRoleList(data) {
  return http({
    method: 'POST',
    url: '/sys/role/list',
    data
  })
}

export function getAllCompany() {
  return http({
    method: 'POST',
    url: '/ykf/dictDetail/listByNo',
    data: { dictNo: 'company' }
  })
}
export function getAllData() {
  return Promise.resolve([
    {
      "dictDetailId": 342,
      "dictId": 27,
      "val": "1",
      "name": "仅看自己",
      "beforeDays": null,
      "sort": 1,
      "remark": "",
      "createUserId": null,
      "createTime": "2024-08-05 21:04:08",
      "dictNo": null,
      "companyNo": null
    },
    // {
    //   "dictDetailId": 343,
    //   "dictId": 27,
    //   "val": "2",
    //   "name": "仅看自己部门",
    //   "beforeDays": null,
    //   "sort": 2,
    //   "remark": "",
    //   "createUserId": null,
    //   "createTime": "2024-08-05 21:04:11",
    //   "dictNo": null,
    //   "companyNo": null
    // },
    {
      "dictDetailId": 344,
      "dictId": 27,
      "val": "3",
      "name": "看全部",
      "beforeDays": null,
      "sort": 3,
      "remark": "",
      "createUserId": null,
      "createTime": "2024-08-05 21:04:12",
      "dictNo": null,
      "companyNo": null
    }
  ])
  // return http({
  //   method: 'POST',
  //   url: '/ykf/dictDetail/listByNo',
  //   data: { dictNo: 'data' }
  // })
}

export function getMenusList() {
  return http({
    method: 'POST',
    url: '/sys/menu/menuList'
  })
}

export function addRole(data) {
  return http({
    method: 'POST',
    url: '/sys/role/save',
    data
  })
}

export function getRoleDetail(data) {
  return http({
    method: 'POST',
    url: '/sys/role/info',
    data
  })
}

export function updateRoleDetail(data) {
  return http({
    method: 'POST',
    url: '/sys/role/update',
    data
  })
}

export function removeRoleDetail(data) {
  return http({
    method: 'POST',
    url: '/sys/role/delete',
    data
  })
}

// 获取员工列表
export function getUserList() {
  return http({
    method: "POST",
    url: '/sys/user/list',
    data: {
      page: { index: 1, size: 9999999999 },
      condition: { keyword: '' }
    }
  }).then(res => {
    return res.list
  })
}

export function searchDispatchUser(data) {
  return http({
    method: 'POST',
    url: '/sys/role/searchDispatchUser',
    data
  }).then(res => {
    return { roleId: data.roleId, userIds: res || [] }
  })
}

export function dispatchUser(data) {
  return http({
    method: 'POST',
    url: '/sys/role/dispatchUser',
    data
  })
}
